package com.miyake.client.datamanage;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.miyake.client.DataServiceAsync;
import com.miyake.client.tools.SmallButton;

public class TablePage extends Page{

	public TablePage(NodeProperty node, VerticalPanel panel) {
		super(node, panel);
	}

	@Override
	protected Widget getContent(NodeProperty node, DataServiceAsync service) {
		VerticalPanel panel = new VerticalPanel();
		panel.setWidth("100%");
		
		if (canEdit()) {
			panel.add(createToolBar());
		}
		
		new ShowEditableTable(node, panel);
		
		return panel;
	}

	private HorizontalPanel createToolBar() {
		HorizontalPanel toolBar = new HorizontalPanel();
		
		toolBar.add(new SmallButton("Text", new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				createHandler.onNewText();
			}
		}));
		toolBar.add(new SmallButton("Insert Row", new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {

			}
		}));
		toolBar.add(new SmallButton("Delete Row", new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {

			}
		}));
		return toolBar;
	}

}
